Only write GIF comments at the beginning of the file#6300
Merged
radarhere merged 7 commits intopython-pillow:mainfrom May 23, 2022
raygard:comment_correct_placement
Merged
Only write GIF comments at the beginning of the file#6300radarhere merged 7 commits intopython-pillow:mainfrom raygard:comment_correct_placement
radarhere merged 7 commits intopython-pillow:mainfrom
raygard:comment_correct_placement
Conversation
Place GIF comment after Global Color table. Should go after "NETSCAPE" looping extension after pull #6211.
for more information, see https://pre-commit.ci
Changed to use a test image already in Images folder
Contributor
Author
|
I updated the tests to use |
Once comment is loaded, keep it for subsequent frames
Contributor
Author
|
@radarhere I am fine with your changes to this. Thanks. |
Member
|
https://github.com/raygard/Pillow/pull/2 keeps the last comment read in With that change, the following code also works before and after this PR, helping backwards compatibility. from PIL import Image
im = Image.new("RGB", (1, 1))
im2 = Image.new("RGB", (1, 1), "#f00")
im.save("out.gif", save_all=True, append_images=[im2], comment=b"comment")
reloaded = Image.open("out.gif")
reloaded.seek(1)
assert reloaded.info["comment"] == b"comment" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Helps #6207
Place GIF comment after Global Color table. Should go after "NETSCAPE" looping extension after pull #6211.
Fixes #6299.
Changes proposed in this pull request:
_write_local_header()to_get_global_header()test_write_comment()to validate that a comment is written to the first frame onlytest_write_no_comment()to validate that an emptycomment=""arg to.saveleaves no comments in saved filemultiple_comments.gifadded in PR Separate multiple GIF comment blocks with newlines #6294 but could use any animated GIF instead — CHANGED todispose_prev.gif’The change here to
_get_global_header()overlaps the change in PR #6211. Please be sure the merge is done so that theif "comment" in info and len(info["comment"]):code in this PR is placed after theif "loop" in info:code in PR #6211. The comment must come after the "NETSCAPE2.0" block.